﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DeleteUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Request.QueryString != null && Request.QueryString.Count > 0)
            {
                ProxyWrapper.UserProxy.UserDetails _objUser = ((ProxyWrapper.UserProxy.UserDetails)Session["UserObject"]);
                int userId = 0;
                Int32.TryParse(Request.QueryString[0].ToString(), out userId);
                ProxyWrapper.UserServiceWrapper _usr = new ProxyWrapper.UserServiceWrapper();
                string msg = _usr.DeleteUser(userId, _objUser.ClientId, _objUser.HashCode);
                if (msg == "0")
                    Response.Redirect("Users.aspx?msg=User deleted.",false);
                else
                    Response.Redirect("Users.aspx?msg=" + msg,false);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("Users.aspx?msg=Error while deleting user  . "+ ex.Message,false);
        }
    }
}